Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Dim ex As String
Function ReadTextFileContents(filename As String) As String
Dim fnum As Integer, isOpen As Boolean
On Error GoTo Error_Handler
' Get the next free file number.
fnum = FreeFile()
Open filename For Input As #fnum
' If execution flow got here, the file has been open without error.
isOpen = True
' Read the entire contents in one single operation.
ReadTextFileContents = Input(LOF(fnum), fnum)
' Intentionally flow into the error handler to close the file.
Error_Handler:
' Raise the error (if any), but first close the file.
If isOpen Then Close #fnum
If Err Then Err.Raise Err.Number, , Err.Description